require("utils/index.js")
var
    e = require("./utils/request"),
    {login} = require("./utils/request"),
    t = (require("utils/weApis"), e.baseURL);
App({
    onShareAppMessage(){
    },
    api: {
        getSpecialUrl: t + "homepage/getSpecial",
        paySuccess: t + "order/paySuccess",
        qeuryPayRes: t + "pay/queryOrder",
    },
    authSetting(res){
        let self = this;
        return new Promise(function (resolve, reject) {
            if (res.detail.errMsg == 'getUserInfo:ok') {
                self.globalData.userInfo = res.detail.userInfo;
                login(res)
                    .then(function (res1) {

                        resolve(res1)
                    })
                    .catch(function (error) { //
                        reject(error);
                    });
            } else {
                reject('您没有授权成功，无法获取！')
            }

        })

    },
    onLaunch: function (t) {
        const self = this;
    },


    goToH5: function (e) {
        e && (e = encodeURIComponent(e)), wx.navigateTo({
            url: "/pages/web/index?url=" + e
        });
    },
    onPageNotFound(res) {
        wx.redirectTo({
            url: 'pages/home2/index.'
        })
    },
    customTabBar: function () {
        var _curPageArr = getCurrentPages();
        var _curPage = _curPageArr[_curPageArr.length - 1];
        var _pagePath = _curPage.__route__;
        if (_pagePath.indexOf('/') != 0) {
            _pagePath = '/' + _pagePath;
        }
        var tabBar = this.globalData.tabBar;
        for (var i = 0; i < tabBar.list.length; i++) {
            tabBar.list[i].active = false;
            if (tabBar.list[i].pagePath == _pagePath) {
                tabBar.list[i].active = true;//根据页面地址设置当前页面状态
            }
        }
        _curPage.setData({
            tabBar: tabBar
        });
     
    },
    globalData: {
        userInfo: null,
        version: "1.0.0",
        tabBar: {
            color: "#a9b7b7",
            borderStyle: "white",
            list: [
                {
                    selectedIconPath: "/image/img/6.png.png",
                    iconPath: "/image/img/6-1.png",
                    pagePath: "/pages/home2/index",
                    clas: "tab-bar-item",
                    label: '软著申请',
                    styl: ""
                },
                {
                    selectedIconPath: "/image/img/7.png.png",
                    iconPath: "/image/img/7-1.png",
                    pagePath: "/pages/enterprise/index",
                    clas: "tab-bar-item",
                    label: '政府项目',
                    styl: ""
                },
                {
                  selectedIconPath: "/image/img/8.png.png",
                  iconPath: "/image/img/8-1.png",
                  pagePath: "/pages/other/index",
                  clas: "tab-bar-item",
                  label: '其它业务',
                  styl: ""
                },
                {
                    selectedIconPath: "/image/img/9.png.png",
                    iconPath: "/image/img/9-1.png",
                    pagePath: "/pages/cart/index",
                    clas: "tab-bar-item",
                    label: '购物车',
                    styl: ""
                },
                {
                    selectedIconPath: "/image/img/10.png.png",
                    iconPath: "/image/img/10-1.png",
                    pagePath: "/pages/my/index",
                    clas: "tab-bar-item",
                    label: '我的',
                    styl: ""
                },
            ],
            position: "bottom"
        }
    }
});
